Tata Infotech Previous Years Solved Sample Placement Papers
-
How do you access the fourth element of an array named numbers?
A: numbers[4];
B: numbers(3);
C: numbers[3];
D: numbers.get(3);
Ans: C -
Which of the following operators is used for concatenation of two strings?
A: +
B: *
C: &
D: +=
Ans: A -
Which of the following creates a mutable string?
A: String
B: StringBuilder
C: StringChar
D: StringMutable
Ans: B -
In Java, strings are:
A: Primitive data types
B: Immutable objects
C: Mutable objects
D: Arrays of characters
Ans: B -
How do you find the length of a string named 'example'?
A: example.size()
B: example.length()
C: example.getLength()
D: example.len()
Ans: B -
What is the result of the expression "Java" + "Programming"?
A: JavaProgramming
B: Java Programming
C: Java-Programming
D: JavaProgramming-
Ans: A -
Which method is used to compare two strings for equality?
A: ==
B: equals()
C: compare()
D: isEqual()
Ans: B -
Which class can create a string that is thread-safe?
A: String
B: StringBuffer
C: StringBuilder
D: StringSafe
Ans: B -
What is the root class for all Java classes?
A: Object
B: Class
C: Superclass
D: Root
Ans: A -
Which keyword is used to create an instance of a class?
A: new
B: return
C: this
D: create
Ans: A -
Which keyword is used to inherit the properties and methods from another class?
A: import
B: package
C: extends
D: implements
Ans: C -
Which keyword is used to refer to the current instance of a class?
A: class
B: this
C: instance
D: object
Ans: B -
Which keyword in Java is used for importing packages into a program?
A: import
B: package
C: include
D: requires
Ans: A